using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MoEngine
{
    public abstract class MasterWindow : WindowBase
    {
        public MasterWindow()
        {
            Core.WndMgr.MasterWindows.Add(this);
        }

        public override Vector2 Position
        {
            get { return Vector2.Zero; }
        }

        public override Vector2 GlobalPosition
        {
            get { return Vector2.Zero; }
        }

        public override MasterWindow MasterWnd
        {
            get { return this; }
        }

        #region Render

        protected GraphicsDevice m_Device;

        public override GraphicsDevice Device
        {
            get { return m_Device; }
        }

        /// <summary>
        /// Draw
        /// </summary>
        /// <param name="gameTime">Game time</param>
        protected override void DrawWindow(GameTime time)
        {
            base.DrawWindow(time);
            ClearBackground();
        }

        public Color BackgroundColor = Color.Black;

        /// <summary>
        /// Clear background
        /// </summary>
        public void ClearBackground()
        {
            //unsure if it clears depth correctly: Device.Clear(BackgroundColor);
            Device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer,
                BackgroundColor, 1.0f, 0);
        }
        #endregion   
 
        public override bool HandleMouseInput(MouseEventType evtType, MouseButtons button, Point mousePos, InputEventArgs evtArgs)
        {
            ValidateLayout();
            m_ChildWnds.HandleMouseInput(evtType, button, mousePos, evtArgs);
            return false;
        }
    }
}
